Skip to content

[module-sdk] Fix WithGroup metric option being silently ignored - #129

Merged
ldmonster merged 4 commits into
mainfrom
fix/metric-expire-not-working
Aug 21, 2026
Merged

[module-sdk] Fix WithGroup metric option being silently ignored#129
ldmonster merged 4 commits into
mainfrom
fix/metric-expire-not-working

Conversation

@riptide-01

@riptide-01 riptide-01 commented Aug 14, 2026

Copy link
Copy Markdown
Member

Description

operation.WithGroup() is the only public way for a Go hook to assign a metric to a group, but it never actually took effect. The option method was declared on a value receiver, so the assignment mutated a copy of the operation and was thrown away, even though the collector correctly applies options through a pointer.

Tests

func handlerHook(_ context.Context, input *pkg.HookInput) error {
	input.MetricsCollector.Set(metricName, 1, map[string]string{"test": "1"}, operation.WithGroup(metricGroup))
	input.MetricsCollector.Set(metricName2, 2, map[string]string{"test": "2"})
	input.MetricsCollector.Expire(metricGroup)
	return nil
}

Before:
image

After:
image

…e return types for MetricOperations functions

Signed-off-by: Smyslov Maxim <maksim.smyslov@flant.com>
Signed-off-by: Smyslov Maxim <maksim.smyslov@flant.com>
Signed-off-by: Smyslov Maxim <maksim.smyslov@flant.com>
Signed-off-by: Smyslov Maxim <maksim.smyslov@flant.com>
@riptide-01
riptide-01 requested a review from ldmonster August 14, 2026 14:34
@riptide-01 riptide-01 self-assigned this Aug 14, 2026
@riptide-01 riptide-01 changed the title Fix/metric expire not working WithGroup() operation don't set the metric group Aug 17, 2026
@riptide-01 riptide-01 changed the title WithGroup() operation don't set the metric group Fix WithGroup metric option being silently ignored Aug 17, 2026
@riptide-01
riptide-01 marked this pull request as ready for review August 17, 2026 07:46
@ldmonster
ldmonster requested a review from ipaqsa August 19, 2026 13:38
@riptide-01 riptide-01 added the enhancement New feature or request label Aug 21, 2026
@riptide-01 riptide-01 changed the title Fix WithGroup metric option being silently ignored [module-sdk] Fix WithGroup metric option being silently ignored Aug 21, 2026
@ldmonster
ldmonster merged commit a39ee4d into main Aug 21, 2026
51 checks passed
@ldmonster
ldmonster deleted the fix/metric-expire-not-working branch August 21, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants